package com.hu.juc.day02.T1;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * 多线程中第三种创建线程的方式
 */
public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask futureTask = new FutureTask(new MyThread());

        System.out.println(Thread.currentThread().getName()+"计算完成");

        //***Callable***  只调用了一次
        new Thread(futureTask, "A").start();
        new Thread(futureTask, "B").start();

        System.out.println(futureTask.get());
    }
}
